package org.example.config;

import org.example.interceptor.LoginCheckInterceptor;
import org.example.interceptor.LoginTicketInterceptor;
import org.example.interceptor.VisitorInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    @Autowired
    private LoginTicketInterceptor loginTicketInterceptor;
    @Autowired
    private VisitorInterceptor visitorInterceptor;
//    @Autowired
//    private LoginCheckInterceptor loginCheckInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //这个一般都拦截servlet资源  不拦截路径也是一样的
        //这样配置拦截器 跟拦截器的配置顺序有关 执行顺序就是配置顺序 可以通过order特别指定
//        registry.addInterceptor(loginCheckInterceptor).addPathPatterns("/**").excludePathPatterns("/**/*.js","/**/*.css","/**/*.jgp","/**/*/png");
        registry.addInterceptor(loginTicketInterceptor).addPathPatterns("/**").excludePathPatterns("/**/*.js", "/**/*.css", "/**/*.jgp", "/**/*/png").order(0);
        registry.addInterceptor(visitorInterceptor).addPathPatterns("/**").excludePathPatterns("/**/*.js", "/**/*.css", "/**/*.jgp", "/**/*/png").order(1);

    }
}
